package com.hzeport.bgs22emduty.inbound.api;

import com.github.pagehelper.PageInfo;
import com.hzeport.bgs22emduty.config.login.LoginCompoentService;
import com.hzeport.bgs22emduty.config.login.UserInfoDetailVO;
import com.hzeport.bgs22emduty.config.systemLog.OperLog;
import com.hzeport.bgs22emduty.dto.DutyScheduleExchangeDTO;
import com.hzeport.bgs22emduty.dto.DutyScheduleExchangeListTureDTO;
import com.hzeport.bgs22emduty.entity.BasePersonInfo;
import com.hzeport.bgs22emduty.entity.ParamSmsTemplate;
import com.hzeport.bgs22emduty.service.BasePersonInfoService;
import com.hzeport.bgs22emduty.vo.DutyScheduleExchange.DutyScheduleExchangeListVO;
import com.hzeport.bgs22emduty.vo.DutyScheduleExchange.DutyScheduleExchangeSaveVO;
import com.hzeport.bgs22emduty.vo.DutyScheduleExchange.DutyScheduleExchangedetailVO;
import com.hzeport.bgs22emduty.vo.ParamHolidays.ParamHolidaysSaveVO;
import com.hzeport.bgs22emduty.vo.base.PageVO;
import com.hzeport.bgs22emduty.common.base.BaseResult;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
////import com.hzeport.bgs22emduty.entity.DutyScheduleExchange;
import com.hzeport.bgs22emduty.service.DutyScheduleExchangeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * ${comments}
 *
 * @author code generator
 * @date 2022-12-02 11:21:59
 */
@RestController
@AllArgsConstructor
@RequestMapping("/dutyscheduleexchange")
@Api(value = "dutyscheduleexchange", tags = "个人调班")
@Slf4j
public class DutyScheduleExchangeController {

    @Resource
    private  DutyScheduleExchangeService dutyScheduleExchangeService;
    @Resource
    private LoginCompoentService loginCompoentService;
    @Resource
    private BasePersonInfoService basePersonInfoService;

    @ApiOperation(value = "调班申请列表")
    @RequestMapping(value = "list",method = RequestMethod.POST)
    public BaseResult<Page<DutyScheduleExchangeListVO>> list(@RequestBody DutyScheduleExchangeDTO exchangeDTO){
        UserInfoDetailVO userInfo = loginCompoentService.getUserInfo();
        return dutyScheduleExchangeService.list(exchangeDTO,userInfo);
    }

    @ApiOperation(value = "获取详情")
    @RequestMapping(value = "detail",method = RequestMethod.GET)
    public BaseResult<DutyScheduleExchangedetailVO> detail(@RequestParam("dId") String dId){
        UserInfoDetailVO userInfo = loginCompoentService.getUserInfo();
        return dutyScheduleExchangeService.detail(dId,userInfo);
    }

    @ApiOperation(value = "保存")
    @RequestMapping(value = "save",method = RequestMethod.POST)
    public BaseResult<DutyScheduleExchange> save(@RequestBody DutyScheduleExchangeSaveVO dutyScheduleExchangeSaveVO) throws Exception {
        UserInfoDetailVO userInfo = loginCompoentService.getUserInfo();
        return dutyScheduleExchangeService.saveData(dutyScheduleExchangeSaveVO,userInfo);
    }

    @ApiOperation(value = "调班确认，待确认列表")
    @RequestMapping(value = "listture",method = RequestMethod.POST)
    public BaseResult<Page<DutyScheduleExchangeListVO>> listture(@RequestBody DutyScheduleExchangeListTureDTO dto) throws Exception {
        UserInfoDetailVO userInfo = loginCompoentService.getUserInfo();
        return dutyScheduleExchangeService.listture(dto,userInfo);
    }

    @ApiOperation(value = "调班确认的接口")
    @RequestMapping(value = "ture",method = RequestMethod.POST)
    public BaseResult<DutyScheduleExchange> ture(@RequestParam("id") String id) throws Exception {
        UserInfoDetailVO userInfo = loginCompoentService.getUserInfo();
        return dutyScheduleExchangeService.ture(id,userInfo);
    }
}



